<template>
    <el-space>
        <div>
            <mi-input v-model="value_c"/>
        </div>
        <el-tooltip content="生成随机昵称">
            <el-button icon="Refresh" @click="makeNickname" />
        </el-tooltip>
    </el-space>
</template>


<script setup lang="ts">

import {computed} from "vue";

const props = withDefaults(defineProps<{
    modelValue?: string,
}>(), {
    modelValue:'',
})
const emits = defineEmits(["update:modelValue"])

const value_c = computed({
    get:() => {
        return props.modelValue
    },
    set: (val: string) => {
        emits("update:modelValue", val)
    }
})

// 随机生成昵称
const makeNickname = () => {
    let e = 6
    const t = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz1234567890"
    const a = t.length
    let n = ""
    for (let i = 0; i < e; i++){
        n += t.charAt(Math.floor(Math.random() * a))
    }
    value_c.value = n
}
</script>

<style scoped>

</style>
